﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WMS.API.Application.Command.DeliveryOrderManagement.DeliveryOrder;
using WMS.Domain.Entities.DeliveryOrderManagement;
using WMS.ErrorCode;

namespace WMS.API.Controllers.DeliveryOrderManagement
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PendingFreightController : ControllerBase
    {
        private readonly IMediator _mediator;

        public PendingFreightController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 查询待发货订单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<PendingFreightModel>>> QueryPendingFreight([FromQuery]QueryPendingFreightCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 删除待发货订单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>>  DeletePendingFreight([FromQuery]DeletePendingFreightCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 修改待发货订单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdatePendingFreight(UpddatePendingFreightCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<List<PendingFreightModel>>> FTPendingFreight([FromQuery]FTPendingFreightCommand request)
        {
            return _mediator.Send(request);
        }

    }
}
